#include "stdafx.h"
#include "ISound.h"
#include "soundbuffer.h"
#include "soundmanager.h"
#include "soundsource.h"

#include <iostream>
#include <string>

using namespace std;

int main(int, char*[])
{
	std::string file;
	cout << "Input a .wav file for listening!\n";
	cin >> file;

	SoundManager sndMng;
	sndMng.Init();
	sndMng.SetVolume( 0.8f );

	SoundSource source, src;
	sndMng.AddSound( &source );
	sndMng.AddSound( &src );
	if ( source.Load( file )&& src.Load(file) )
		cout << "Failed to load " + file + "\n";
	//source.Volume(1.0f);
	source.Play(true);
	//src.Volume( 0.9f );
	src.Play( true );
	char q = 0;
	while(1) {
		cin >> q;
		switch(q)
		{
		case 'q': return 0;
			break;
		case 'u': sndMng.SetVolume( sndMng.GetVolume()+0.1f );
			break;
		case 'l': sndMng.SetVolume( sndMng.GetVolume()-0.1f );
			break;
		case 'p': source.Pause(); break;
		case 'r': source.Resume(); break;
		case 's': source.Stop(); break;
		case 'm': sndMng.Mute( !sndMng.IsMute() ); break;
		};
		sndMng.Update(1);
	}
	sndMng.Shutdown();

	return 0;
}